<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	<script type="text/javascript">
		//5. 改进上面计算年龄的例子，如果当前月日超过生日的月日，那么年龄+1。
		function Human(name, sex, birthday) {
			this.name = name;
			this.sex = sex;
			this.birthday = birthday;
			this.getAge = function() {
				let date = new Date();
				let year = date.getFullYear();
				        
				let birthDate = new Date(this.birthday);
				let birthYear = birthDate.getFullYear();
			
				if(birthDate>birthYear){
					return (year - birthYear)+1;
				}
				
				
			}
		}
		let human = new Human("鬼谷子", "男", "2002-07-28");
	
	    console.log(human.getAge()); 
			
			</script>
	</body>
</html>
